<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @author Thanh Nguyen Dinh<thanhnguyendinh@admicro.vn>
 * @copyright 2013
 */
class Feedback extends MX_Controller
{
    
    public function __construct()
    {
        parent::__construct();
        $this->load->library('Default_Layout');
        $this->load->library('Minifier');
        $this->load->model('contact/contact_model');
    }

    public function index()    
    {     
        $data =array();
        $input = $this->input->post();
        $data['ok'] = 0;           
        $this->minifier->AddJsNoPack('jquery.validate');
        $this->default_layout->_loadHeader('');  
        if($this->input->post()){          	     	   
	     	if($input['name'] && $input['email'] && $input['phone'] && $input['content'] && $input['service'] && $input['bussiness'] && strlen($input['name']) > 9 && strlen($input['phone']) > 5 ){
	            unset($input['Submit']);
	            $data_feedback = array('name'=>$input['name'],
	            						'email'=>$input['email'],
	            						'phone'=>$input['phone'],
	            						'service'=>$input['service'],
	            						'bussiness'=>$input['bussiness'],
	            						'content'=>$input['content'],
	            						'phone'=>$input['phone'],
	            						'idea'=>$input['idea'][0],
	            						'reply'=>$input['reply'][0],
	            						'type'=>2,
	            						'status'=>1	
	            						);
	            $return = $this->contact_model->insert_contact($data_feedback);
	            if($return)
	            	$data['ok'] = 1;	            
	        }
        }
        $data['frmToken'] = uniqid();
        $this->session->set_userdata('frmToken',$data['frmToken']);
        $this->load->view('feedback/feedback_view',$data);     
        $this->default_layout->_loadFooter();    
    }

}

?>
